<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ page import="com.zhangmengyuan.medical.entity.Goods" %>
<%@ page import="com.zhangmengyuan.medical.entity.User" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<!-- Template Name: Clip-One - Responsive Admin Template build with Twitter Bootstrap 3.x Version: 1.3 Author: ClipTheme -->
<!--[if IE 8]><html class="ie8 no-js" lang="en"><![endif]-->
<!--[if IE 9]><html class="ie9 no-js" lang="en"><![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- start: HEAD -->
<head>
    <base href="<%=basePath%>">
    <meta charset="utf-8"/>
    <title>结算中心</title>
    <link rel="stylesheet" type="text/css" href="css/basic.css" />
    <link rel="stylesheet" type="text/css" href="css/cart.css" />
    <script src="ajax/cartAjax.js" type="text/javascript"></script>
    <script src="js/order.js" type="text/javascript"></script>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css"
          href="http://cdn.datatables.net/1.10.15/css/jquery.dataTables.css">
</head>

<body>
<div id="header">
    <%
        Map<Integer,Goods> map = (Map<Integer,Goods>)session.getAttribute("goodsCart");
    %>
</div>
<div class="top">
    <c:choose>
        <c:when test="${user.userName!=null}">
            <span>${sessionScope.user.userName}欢迎您</span>
        </c:when>
        <c:when test="${user.userName!=null}">[<a href="register.jsp">登录</a>][<a href="login.jsp">注册</a>]</c:when>

    </c:choose>
</div>
<div class="cart">
    您的<a href="cart.jsp">购物车</a>&nbsp;&nbsp;目前有<strong><%=map!=null?map.size():0 %></strong>件商品
</div>
<div id="nav">
    <ul>
        <li><a href="index.jsp">首页</a> </li>
        <li><a href="index.jsp">家用器械</a> </li>
        <li><a href="index.jsp">医用器械</a> </li>
        <li><a href="index.jsp">保健养生</a> </li>
        <li><a href="index.jsp">健康中心</a> </li>
        <li><a href="index.jsp">服务中心</a> </li>

    </ul>
</div>
<%
    User u = (User) session.getAttribute("user");
    if (u == null) {
%>
<jsp:forward page="login.jsp"></jsp:forward>
<%
}
else {
%>
<form action="OrderServlet?service=add" method="post" onSubmit="return check();">
    <div id="user" >
        <table align="center" width="100px" style="font-size: 13px;">
            <tr height="40px;">
                <td colspan="2">请确认您的信息</td>
            </tr>
            <tr>
                <td>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</td>
                <td><%=u.getUserName()%></td>
            </tr>
            <tr>
                <td>联系方式：</td>
                <td><%=u.getPhone()%></td>
            </tr>
            <tr>
                <td>邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;箱：</td>
                <td><%=u.getEmail()%></td>
            </tr>
        </table>
    </div>
    <div id="order">
        <table width="400px;" style="margin-left: 100px;">
            <tr>
                <td>收件人信息</td>
            </tr>
            <tr>
                <td width="200px;">
                    <select id="se_touser" name="se_touser" onChange="playmy(this.value)">
                        <option value="0">自己</option>
                        <option value="1">新建联系人</option>
                    </select>
                    <div id="myInfo" style="display: block">
                        <table style="font-family: '雅黑'" align="center">
                            <tr height="30px;">
                                <td>姓名：</td>
                                <td><%=u.getUserName()%></td>
                            </tr>
                            <tr height="30px;">
                                <td>联系方式：</td>
                                <td><%=u.getPhone()%></td>
                            </tr>
                            <tr height="30px;">
                                <td>地址：</td>
                                <td><%=u.getAddress()%></td>
                            </tr>
                            <tr height="30px;">
                                <td>邮编：</td>
                                <td><%=u.getPostCode()%></td>
                            </tr>
                        </table>
                    </div>
                    <div id="newInfo" style="display: none">
                        <table style="font-family: '雅黑'" align="center">
                            <tr height="30px;">
                                <td>姓名：</td>
                                <td><input type="text" id="toUser" name="toUser"></td>
                            </tr>
                            <tr height="30px;">
                                <td>联系方式：</td>
                                <td><input type="text" id="toPhone" name="toPhone"></td>
                            </tr>
                            <tr height="30px;">
                                <td>地址：</td>
                                <td><input type="text" id="toAddress" name="toAddress"></td>
                            </tr>
                            <tr height="30px;">
                                <td>邮编：</td>
                                <td><input type="text" id="toPostCode" name="toPostCode"></td>
                            </tr>
                        </table>
                    </div></td>
            </tr>
        </table>
    </div>
    <%
        }
    %>
    <div id="goods">
        <table align="center" width="1000px" border="1" cellspacing="0"
               bordercolordark="#FFFFFF" bordercolorlight="#FCDEDE"
               style="font-size: 12px;">
            <tr>
                <th width="100px;">商品图片</th>
                <th width="100px;">商品名称</th>
                <th width="100px;">商品价格</th>
                <th width="100px;">商品数量</th>
                <th width="100px;">总额</th>
            </tr>
            <tbody>
            <%
                int price = 0;
                if (map != null) {
                    Set s = map.keySet();
            %>
            <%
                Iterator it = s.iterator();
                while (it.hasNext()) {
                    Goods goods = map.get(it.next());
                    price = price + goods.getPrice()
                            * goods.getCart_num();
            %>
            <tr align="center">
                <td><img src="img/<%=goods.getPicPath()%>" /></td>
                <td><%=goods.getGoodsName()%></td>
                <td><%=goods.getPrice()%></td>
                <td><%=goods.getCart_num()%></td>
                <td><%=goods.getPrice() * goods.getCart_num()%></td>
            </tr>
            <%
                }
            %>
            <tr align="center" height="50px">
                <td colspan="5" style="font-size: 14pt; color: black;">合计：<%=price %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
                    <input type="submit" value="提交订单"></td>
            </tr>
            </tbody>
                <%} %>
    </div>
</form>
<div class="w990" style="margin-top: 30px">
    <div class="footer-link">
        <a href="http://www.yiliu88.com/helpcenter/zizhi.aspx#jyfw">互联网药品交易服务资格证</a>
        <a href="http://www.yiliu88.com/helpcenter/zizhi.aspx#xxfw">互联网药品信息服务资格证</a>
        <a href="http://www.yiliu88.com/helpcenter/zizhi.aspx#jyxk">医疗器械经营许可证</a>
        <a href="http://www.yiliu88.com/helpcenter/zizhi.aspx#zzdx">增值电信业务经营许可证</a>
        <hr style="color: #cccccc" size="1px"/></div>
    <div class="call" >
        客户服务热线：400-111-0000
    </div>
    <div class="copyright"></div>
    <span>
        Copyright&copy;&nbsp;2018&nbsp;&nbsp;医疗器械<a href='index.jsp'>www.ylqx.com</a>商城保留一切权利。
        &nbsp;All Rights Reserved.&nbsp;&nbsp;<br />
        &nbsp;&nbsp;
        地址：河南省平顶山市平顶山学院&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    </span>
</div>

</body>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>


</html>